package com.chinanet.utils.pon;

import java.io.*;
import java.net.Socket;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class ZX_SocketClient {
	
	private String ip;
	private int port;

	public ZX_SocketClient(String ip, int port) {
		this.ip = ip;
		this.port = port;
	}

	/**
	 * initfunction
	 * 
	 * @param hattr
	 * @param type
	 * @return
	 */
	public Map<String, Object> init(HW_Socket_AttrsIn hattr, OperationType type) {
		Map<String, Object> map = new HashMap<String, Object>();
		Socket socket = null;
		PrintWriter pw = null;
		InputStream in = null;
		// list的第一个代表成功与否，第二个代表自身log,第三个代表总log;
		List<Object> step = null;
		// 总日志
		String log = "";
		try {
			socket = new Socket(ip, port);
			pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
					socket.getOutputStream())));
			in = socket.getInputStream();

			//中兴的北向接口不需要登录
					if (type == OperationType.TYPE_Query_FTTP__LST_LANPORT_Speed) {
						step = Query_FTTP_LST_LANPORT_Speed(pw, in,
								hattr.getOLTID(), hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(),hattr.getPORTID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_MDU__LST_LANPORT_Speed) {
						step = Query_MDU__LST_LANPORT_Speed(pw, in,
								hattr.getONUIP(),hattr.getPORTID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_PON_port_luminous_power) {
						step = Query_PON_port_luminous_power(pw, in,
								hattr.getOLTID(),hattr.getPONID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_PON_port_ONU_luminous_power) {
						step = Query_PON_port_ONU_luminous_power(pw, in,
								hattr.getOLTID(),hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Set_LANPORT_Speed) {
						step = Set_LANPORT_Speed(pw, in,
								hattr.getOLTID(),hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(),hattr.getUPBW(),hattr.getDOWNBW(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_UNI_INFO) {
						step = Query_UNI_INFO(pw, in,
								hattr.getOLTID(),hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_ONU_STATE) {
						step = Query_ONU_STATE(pw, in,
								hattr.getOLTID(),hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_ONU_AgreementAndIp) {
						step = Query_ONU_AgreementAndIp(pw, in,
								hattr.getOLTID(),hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_UserNumber) {
						step = Query_UserNumber(pw, in,
								hattr.getOLTID(),hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(),hattr.getONUPORT(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_ONU_Version) {
						step = Query_ONU_Version(pw, in,
								hattr.getDID(),hattr.getPID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_Serviceport_Rate) {
						step = Query_Serviceport_Rate(pw, in,
								hattr.getOLTID(),hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_LST_VOIPINFO) {
						step = Query_LST_VOIPINFO(pw, in,
								hattr.getOLTID(),hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(),hattr.getONUPORT(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Simulation) {
						if(hattr.getFlag()==1){
							step = passiveSimulation(pw, in,hattr.getONUIP(),hattr.getONUPORT(), log);
						}else if(hattr.getFlag()==2){
							step = initiativeSimulation(pw, in,hattr.getONUIP(),hattr.getONUPORT(),hattr.getTEL(), log);
						}

						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_OLT_CRC) {
						step = Query_OLT_CRC(pw, in,
								hattr.getOLTID(),hattr.getPORTID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_PON_CRC) {
						step = Query_PON_CRC(pw, in,
								hattr.getOLTID(),hattr.getPONID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_Query_PON_OLT_under_the_number_of_alarms) {
						step = Query_PON_OLT_under_the_number_of_alarms(pw, in,
								hattr.getOLTID(), hattr.getPONID(),
								hattr.getBEGINTIME(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;

					}else if (type == OperationType.TYPE_Query_Cheack41_Bussinessbits) {
						step = Query_Cheack41_Bussinessbits(pw, in,
								hattr.getOLTID(),hattr.getPONID(),hattr.getONUIDTYPE(),hattr.getONUID(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;

					}else if (type == OperationType.TYPE_RESET_ONU) {
						step = Query_Reset_Onu(pw, in,
								hattr.getONUID(),hattr.getONUPORT(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_ZXFTTHB_RESETONU_MANAGER) {
						step = FTTNB_RESETONU_MANAGER(pw, in,
								hattr.getONUID(),hattr.getONUPORT(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if (type == OperationType.TYPE_ZXFTTHB_RESETONU_NOMANAGER) {
						step = FTTNB_RESETONU_NOMANAGER(pw, in,
								hattr.getONUID(),hattr.getONUPORT(), log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}else if(type==OperationType.TYPE_ZX_Query_PON_ITV43){
						step = ITV43(pw, in,hattr.getOLTID(),hattr.getPONID(),hattr.getONUID(),hattr.getONUIDTYPE(),hattr.getSVLAN(),hattr.getCVLAN(),hattr.getMAXGRP(),log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}
					else if(type==OperationType.TYPE_ZX_Query_PON_VOICE_46){
						step = VOICE_46(pw, in,hattr.getOLTID(),hattr.getPONID(),hattr.getONUID(),hattr.getONUIDTYPE(),hattr.getSVLAN(),hattr.getCVLAN(),log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}
					else if(type==OperationType.TYPE_ZX_Query_PON_Broadband_41){
						step = New_Broadband_41(pw, in,hattr.getOLTID(),hattr.getPONID(),hattr.getONUID(),hattr.getONUIDTYPE(),hattr.getSVLAN(),hattr.getCVLAN(),log);
						boolean flag = (Boolean) step.get(0);
						map.put("flag", flag);
						map.put("ownlog", step.get(1));
						map.put("log", step.get(2));
						return map;
					}
					

		} catch (Exception e) {
			StringWriter sw = new StringWriter();
			PrintWriter pwtwo = new PrintWriter(sw);
			e.printStackTrace(pwtwo);
			map.put("flag", false);
			map.put("log", "time out!");
			return map;

		} finally {
			try {
				pw.close();
			} catch (Exception e2) {
				map.put("flag", false);
				map.put("log", "time out!");
				return map;
			}
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			try {
				socket.close();
			} catch (IOException e) {
				e.printStackTrace();
			}

		}
		return map;

	}

	
	public List<Object> Query_FTTP_LST_LANPORT_Speed(PrintWriter pw,
			InputStream in, String OLTID, String PONID,String ONUIDTYPE,String ONUID,String PORTID, String log) {
		String cmd = "LST-LANPORT::OLTID=" + OLTID + ",PONID=" +PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID+",PORTID="+PORTID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	

	public List<Object> Query_MDU__LST_LANPORT_Speed(PrintWriter pw,
			InputStream in,String ONUIP,String PORTID, String log) {
		String cmd = "LST-LANPORT::ONUIP="+ONUIP+",PORTID="+PORTID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	
	public List<Object> Query_PON_port_luminous_power(PrintWriter pw,
			InputStream in,String OLTID,String PONID, String log) {
		String cmd = "LST-OMDDM::OLTID="+OLTID+",PONID="+PONID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}

	

	public List<Object> Query_PON_port_ONU_luminous_power(PrintWriter pw,
			InputStream in,String OLTID,String PONID,String ONUIDTYPE,String ONUID, String log) {
		String cmd = "LST-OMDDM::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	public List<Object> Set_LANPORT_Speed(PrintWriter pw,
			InputStream in,String OLTID,String PONID,String ONUIDTYPE,String ONUID,String UPBW,String DOWNBW, String log) {
		String cmd = "CFG-ONUBW::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID
				+ ":CTAG::UPBW="+UPBW+",DOWNBW="+DOWNBW+";";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	public List<Object> Query_UNI_INFO(PrintWriter pw,
			InputStream in,String OLTID,String PONID,String ONUIDTYPE,String ONUID, String log) {
		String cmd = "LST-LANPORT::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	public List<Object> Query_ONU_STATE(PrintWriter pw,
			InputStream in,String OLTID,String PONID,String ONUIDTYPE,String ONUID, String log) {
		String cmd = "LST-ONUSTATE::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	public List<Object> Query_ONU_AgreementAndIp(PrintWriter pw,
			InputStream in,String OLTID,String PONID,String ONUIDTYPE,String ONUID, String log) {
		String cmd = "LST-MG::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	
	public List<Object> Query_UserNumber(PrintWriter pw,
			InputStream in,String OLTID,String PONID,String ONUIDTYPE,String ONUID, String ONUPORT,String log) {
		String cmd = "LST-POTS::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID+",ONUPORT="+ONUPORT
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	


	public List<Object> Query_ONU_Version(PrintWriter pw,
			InputStream in,String DID,String PID,String log) {
		String cmd = "LST-ONU-PON::DID="+DID+",PID="+PID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	
	public List<Object> Query_Serviceport_Rate(PrintWriter pw,
			InputStream in,String OLTID,String PONID,String ONUIDTYPE,String ONUID, String log) {
		String cmd = "LST-ONUCFG::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	public List<Object> Query_LST_VOIPINFO(PrintWriter pw,
			InputStream in,String OLTID,String PONID,String ONUIDTYPE,String ONUID, String ONUPORT,String log) {
		String cmd = "LST-VOIPINFO::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID+",ONUPORT="+ONUPORT
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	
//	TEST-CALLERSIMULATION::ONUIP=10.132.17.194,ONUPORT=1-1-1-1:CTAG::ACTION=Query,TEL=018106880613,TIMEOUT=60;
	public List<Object> initiativeSimulation(PrintWriter pw,
			InputStream in,String ONUIP,String ONUPORT,String TEL,String log) {
		String cmd = "TEST-CALLERSIMULATION::ONUIP="+ONUIP+",ONUPORT="+ONUPORT
				+ ":CTAG::ACTION=Query,TEL="+TEL+",TIMEOUT=60;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	public List<Object> passiveSimulation(PrintWriter pw,
			InputStream in,String ONUIP,String ONUPORT,String log) {
		String cmd = "TEST-CALLEESIMULATION::ONUIP="+ONUIP+",ONUPORT="+ONUPORT
				+ ":CTAG::ACTION=Stop,TIMEOUT=60;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}

	
	public List<Object> Query_OLT_CRC(PrintWriter pw,
			InputStream in,String OLTID,String PORTID, String log) {
		String cmd = "LST-LANPERF::OLTID="+OLTID+",PORTID="+PORTID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	public List<Object> Query_PON_CRC(PrintWriter pw,
			InputStream in,String OLTID,String PONID, String log) {
		String cmd = "LST-PONPERF::OLTID="+OLTID+",PONID="+PONID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	public List<Object> Query_PON_OLT_under_the_number_of_alarms(
			PrintWriter pw, InputStream in, String OLTID, String PONID,
			String BEGINTIME, String log) {
		String cmd = "LST-ALARM::OLTID=" + OLTID + ",PONID=" + PONID
				+ ":CTAG::BEGINTIME=" + BEGINTIME +",FAULTFLAG=all;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	public List<Object> Query_Cheack41_Bussinessbits(PrintWriter pw,
			InputStream in,String OLTID,String PONID,String ONUIDTYPE,String ONUID, String log) {
		String cmd = "LST-PORTVLAN::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE+",ONUID="+ONUID
				+ ":CTAG::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	
	/**
	 * 执行输出
	 * 
	 * @param in
	 * @param log
	 * @return
	 */
	private List<Object> initLogOut(InputStream in, String log) {
		// list的第一个代表成功与否，第二个代表自身log,第三个代表总log;
		List<Object> loginLogs = new ArrayList<Object>();
		byte[] b = new byte[1024];
		StringBuffer sb = new StringBuffer();
		int len = 0;
		boolean flag = false;
		boolean flagtrue = false;
		boolean flagfalse = false;
		try {
			while((len=in.read(b))!=-1){
				String str=new String(b,0,len,"gbk");
				sb.append(str);	
				if ((str.indexOf("total_blocks")) != -1||(str.indexOf("EN=0")!=-1)) {
					flagtrue = true;
				}
				if ((str.indexOf("EN=IRNE")) != -1 ||(str.indexOf("EN=IRAE")) != -1 ||(str.indexOf("EN=IRC(")) != -1 ||(str.indexOf("EN=IANE")) != -1
						 ||(str.indexOf("EN=IMP")) != -1 ||(str.indexOf("EN=IIPF")) != -1 ||(str.indexOf("EN=IIPE")) != -1 ||(str.indexOf("EN=DDNS")) != -1
						 ||(str.indexOf("EN=DDOF")) != -1 ||(str.indexOf("EN=DDB")) != -1 ||(str.indexOf("EN=SENS")) != -1 ||(str.indexOf("EN=SEOF")) != -1
						 ||(str.indexOf("EN=EEEH")) != -1 ||(str.indexOf("EN=TUB")) != -1 ||(str.indexOf("EN=TUT")) != -1 ||(str.indexOf("EN=TTMB")) != -1) {	
					flagfalse = true;
				}
				if (flagtrue && (str.indexOf(";")) != -1) {
					flag = true;
					break;
				}
				if (flagfalse && (str.indexOf(";")) != -1) {
				
					break;
				}
			}
			log += sb.toString();
			loginLogs.add(flag);
			loginLogs.add(sb.toString());
			loginLogs.add(log);
			return loginLogs;
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return loginLogs;

	}
	/**
	 * @description 中兴ONU重启
	 * @Author jwing
	 * @Date 17:24 2018/1/15
	 */
	private List<Object> Query_Reset_Onu(PrintWriter pw,
										 InputStream in,String DID,String OID, String log) {
		String cmd = "RST-ONU-PON::DID=" + DID + ",OID=" + OID + ":CTAG001::;";
		// initQuery
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}
	/**
	 * @description 中兴ONU去激活再激活(不具有独立管理IP)
	 * @Author jwing
	 * @Date 9:21 2018/1/16
	 */
	public List<Object> FTTNB_RESETONU_NOMANAGER(PrintWriter pw,
												 InputStream in,String ONUIP,String ONUPORT, String log) {
		// TODO: 不具有独立管理IP指令未确认
		return null;
	}
	/**
	 * @description 中兴ONU去激活再激活(具有独立管理IP)
	 * @Author jwing
	 * @Date 9:21 2018/1/16
	 */
	public List<Object> FTTNB_RESETONU_MANAGER(PrintWriter pw,
											   InputStream in,String ONUIP,String ONUPORT, String log) {
		// 去激活
		String cmd = "DACT-LANPORT::ONUIP="+ONUIP+",ONUPORT=" + ONUPORT + ":CTAG::;";
		pw.write(cmd);
		pw.flush();
		List<Object> result = initLogOut(in, log);
		if ((Boolean) result.get(0) == false) { // 去激活失败
			return result;
		}
		log = result.get(2).toString();
		// 激活
		cmd = "ACT-LANPORT::ONUIP="+ONUIP+",ONUPORT=" + ONUPORT + ":CTAG::;";
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}

	/**
	 * @author zsf
	 * @date 2018/1/30 13:43
	 * @return java.util.List<java.lang.Object>
	 * @desc 中兴PON网管新建宽带41
	 */
	public List<Object> New_Broadband_41(PrintWriter pw,InputStream in,String OLTID,String PONID, String ONUID,String ONUIDTYPE,String SVLAN,String CVLAN,String log) {

		//TODO 指令可能会改
		String cmd = "ADD-PONVLAN::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE
						+",ONUID="+ONUID+":CTAG::SVLAN="+SVLAN+",CVLAN="+CVLAN+",UV=41;";
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}

	/**
	 * @author zsf
	 * @date 2018/1/30 13:43
	 * @return java.util.List<java.lang.Object>
	 * @desc 中兴PON网管语音46
	 */
	public List<Object>VOICE_46 (PrintWriter pw,InputStream in,String OLTID,String PONID, String ONUID,String ONUIDTYPE,String SVLAN,String CVLAN,String log) {

		//TODO 指令可能会改
		String cmd = "ADD-PONVLAN::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE
						+",ONUID="+ONUID+":CTAG::SVLAN="+SVLAN+",CVLAN="+CVLAN+",UV=46;";
		pw.write(cmd);
		pw.flush();
		return initLogOut(in, log);
	}

	/**
	 * @author zsf
	 * @date 2018/1/30 13:43
	 * @return java.util.List<java.lang.Object>
	 * @desc 中兴PON网管ITV43
	 */
	public List<Object> ITV43(PrintWriter pw,InputStream in,String OLTID,String PONID, String ONUID,String ONUIDTYPE,String SVLAN,String CVLAN,String MAXGRP,String log) throws InterruptedException {

		//TODO 指令可能会改
		//开通IPTV业务流
		String cmd = "ADD-PONVLAN::OLTID="+OLTID+",PONID="+PONID+",ONUIDTYPE="+ONUIDTYPE
						+",ONUID="+ONUID+":CTAG::SVLAN="+SVLAN+",CVLAN="+CVLAN+",UV=43;";
		pw.write(cmd);
		pw.flush();
		List<Object> result = initLogOut(in, log);
		log = result.get(2).toString();
		Thread.sleep(2000);
		if((Boolean) result.get(0)) {
			//用户加入组播vlan
			cmd = "ADD-PONVLAN::OLTID=" + OLTID + ",PONID=" + PONID + ",ONUIDTYPE=" + ONUIDTYPE
					+ ",ONUID=" + ONUID + ":CTAG::CVLAN=4000,UV=4000;";
			pw.write(cmd);
			pw.flush();
			result = initLogOut(in, log);
		}
		return result;
	}

}
